<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div class="container">
        <h2>nb自动售货机</h2>
        <div class="type">
            <button @click="fn(5)">可乐5元</button>
            <button @click="fn(10)">咖啡10元</button>
            <button @click="fn(8)">牛奶8元</button>
        </div>
        <p>银行卡余额:{{totalmony}}</p>
        <input type="text" @input="result = $event.target.value">
        <span>{{result}}</span>

    </div>
    <style>
        *{
            padding: 0;
            margin: 0;
            box-sizing: content-box;
        }
        .container {
            height: 400px;
            width: 500px;
            text-align: center;
            padding: 20px 0 0;
            margin: 50px auto;
            background-color: pink;

        }
        .container .type {
            display: flex;
            justify-content: space-between;
            margin: 50px auto;
            width: 300px;
        }
        .container p {
            text-align: left;
            margin-left: 50px;
        }
    </style>
    <script src="./js/vue.js"></script>
    <script>
        const app = new Vue({
            el:".container",
            data:{
                totalmony:100,
                result:"",
            },
            methods:{
                fn(price){
                    this.totalmony = this.totalmony - price
                }
            }
        })
    </script>
</body>

</html>